<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
<script>
  // 求一个三位数，叫做“喇叭花数”，该三位数等与其每位数字的阶乘之和。输出100~999的所有喇叭花数。
  
  //定义函数
  function jiecheng(num){
    if(num == 1 || num == 0){
      return 1;
    }
    return num * jiecheng(num-1);
  }

  function isFlowerNum(num){
    //百位
    var n1 = Math.floor(num / 100);
    //十位
    var n2 = parseInt(num / 10) % 10;
    //个位
    var n3 = num % 10;
    var sum = jiecheng(n1) + jiecheng(n2) + jiecheng(n3);
    return sum == num;
  }

  //主程序
  for(var i = 100; i <=999; i++){
    if(isFlowerNum(i)){
      console.log(i);
    }
  }
</script>
</html>